package com.ymatou.query.trading.api.testcase;

import java.math.BigDecimal;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetUseGiftAmountBean;
import com.ymatou.query.trading.api.service.GetUseGiftAmountCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.utils.constant.ECode;

/**
 * 获取最大可用红包金额 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetUseGiftAmount {

	private static GetUseGiftAmountBean getusegiftamountbean;
	private static GetUseGiftAmountCall getusegiftamountcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取最大可用红包金额");
	}

	@Before
	public void caseUp() {

		getusegiftamountbean = new GetUseGiftAmountBean();
		getusegiftamountcall = new GetUseGiftAmountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getusegiftamountcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetUseGiftAmount_001() {
		Logger.start(true,"获取最大可用红包金额成功");
		try {
			// 参数
			BigDecimal price = new BigDecimal(101);
			getusegiftamountbean.setOrderPrice(price);
			// 发送请求
			getusegiftamountcall.setData(getusegiftamountbean);
			getusegiftamountcall.callService();
			Logger.comment("getusegiftamountcall send:" + getusegiftamountcall.getEntityString());
			Logger.comment("getusegiftamountcall response:" + getusegiftamountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getusegiftamountcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getusegiftamountcall.getMsg(), "验证Msg");
			Logger.verifyEquals(price.divide(new BigDecimal(2)), getusegiftamountcall.getGiftAmount(), "验证红包可支付金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUseGiftAmount_002() {
		Logger.start(true,"订单金额为0");
		try {
			// 参数
			BigDecimal price = new BigDecimal(101);
			// getusegiftamountbean.setOrderPrice(price);
			// 发送请求
			getusegiftamountcall.setData(getusegiftamountbean);
			getusegiftamountcall.callService();
			Logger.comment("getusegiftamountcall send:" + getusegiftamountcall.getEntityString());
			Logger.comment("getusegiftamountcall response:" + getusegiftamountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getusegiftamountcall.getCode(), "验证Code");
			Logger.verifyEquals(new BigDecimal(0), getusegiftamountcall.getGiftAmount(), "验证红包可支付金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUseGiftAmount_003() {
		Logger.start(true,"订单金额为1");
		try {
			// 参数
			BigDecimal price = new BigDecimal(1);
			getusegiftamountbean.setOrderPrice(price);
			// 发送请求
			getusegiftamountcall.setData(getusegiftamountbean);
			getusegiftamountcall.callService();
			Logger.comment("getusegiftamountcall send:" + getusegiftamountcall.getEntityString());
			Logger.comment("getusegiftamountcall response:" + getusegiftamountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getusegiftamountcall.getCode(), "验证Code");
			Logger.verifyEquals(price.divide(new BigDecimal(2)), getusegiftamountcall.getGiftAmount(), "验证红包可支付金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}